#ifndef __CACHE_H__  //检查该头文件是否被包含，防止多次包含，头文件保护
#define __CACHE_H__

#include "common.h"

#define cache1_s 7 //组索引的位数
#define cache_b 6 //块偏移的位数

#define cache1_E 8 //8路组
#define cache1_S 128 //组数量
#define cache_B 64 //块大小

struct cache_l1{
    bool valid;
    int tag;
    uint8_t cache_line[cache_B];
} cache1[cache1_E * cache1_S];


#define cache2_s 12 

#define cache2_E 16
#define cache2_S (1 << cache2_s) 


struct cache_l2{
    bool valid;
    bool dirty;
    uint32_t tag;
    uint8_t cache_line[cache_B];
} cache2[cache2_E * cache2_S];

void init_cache();
uint32_t cache1_read(hwaddr_t addr); //统一读32位字节，之后在memory.c里进行掩码处理
void cache1_write(hwaddr_t addr,size_t len,uint32_t data);
//size_t无符号整型，可处理任意类型的数据
uint32_t cache2_read(hwaddr_t addr); //统一读32位字节，之后在memory.c里进行掩码处理
void cache2_write(hwaddr_t addr,size_t len,uint32_t data);


#endif